package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.entity.pojo.LfRecruitment;
import com.mapper.LfRecruitmentMapper;
import com.service.RecruitmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service("RecruitmentService")
public class RecruitmentServiceImpl implements RecruitmentService {

    @Resource
    private LfRecruitmentMapper recruitmentMapper;

    @Override
    public int addRecruitment(LfRecruitment recruitment) {
        return recruitmentMapper.insert(recruitment.setCreateTime(LocalDateTime.now()));
    }

    @Override
    public List<LfRecruitment> listRecruitment() {
        return recruitmentMapper.selectList(new QueryWrapper<LfRecruitment>().eq("deleted", 0));
    }

    @Override
    public int deleteOne(Integer id) {
        return recruitmentMapper.updateById(new LfRecruitment().setId(id).setDeleted(1).setUpdateTime(LocalDateTime.now()));
    }
}
